const express = require('express');
const bodyParser = require('body-parser');
const path = require('node:path');
const mainRT = require(path.resolve(__dirname, './routes/mainRT.js'));

const app = express();

app.use((req, res, next) => {
	res.setHeader('Access-Control-Allow-Origin', '*'); //配置允许跨域的Origin
	res.setHeader('Access-Control-Allow-Methods', '*'); //配置允许访问的方法
	res.setHeader('Access-Control-Allow-Headers', 'Content-type,authorization'); //配置允许携带的请求头
	next();
});

app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(bodyParser.json({ limit: '5000000000kb' }));

app.use('/', mainRT['userRT']); //使用userRT路由
app.use('/', mainRT['blogRT']); //使用blogRT路由
app.use('/', mainRT['commentRT']); //使用commentRT路由

app.listen(5000, () => {
	console.log('服务器已启动，端口号是5000');
});
